import forge from "node-forge";
import store from "../store";

const publicKey = forge.pki.publicKeyFromPem(store().publicKey);
export default function (data: string) {
    const encrypted = publicKey.encrypt(data, "RSA-OAEP", {
        md: forge.md.sha256.create(),
        mgf1: {
            md: forge.md.sha1.create()
        }
    });
    return forge.util.encode64(encrypted);
}
